<?php

namespace App\Models;

use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Player extends Authenticatable implements JWTSubject
{

    //
    protected $table = 'player';

    protected $fillable = [
        'player',
        'password',
        'avatar',
        'introduction',
    ];

    public function getCreatedAtAttribute($value)
    {
        return date('Y-m-d H:i:s', strtotime($value));
    }

    public function getUpdatedAtAttribute($value)
    {
        return date('Y-m-d H:i:s', strtotime($value));
    }

    public function reward()
    {
        return $this->hasOne(Reward::class, 'player_id', 'id');
    }

    public function wechat()
    {
        return $this->hasOne(PlayerWechat::class, 'player_id', 'id');
    }

    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    public function getJWTCustomClaims()
    {
        return [];
    }
}
